package pri.jz.keeper.jui

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import pri.jz.keeper.ui.theme.Grey3
import pri.jz.keeper.ui.theme.Shapes

/**
 *Author by: JZ
 *Email: 2451756617@qq.com
 *PS:
 */
@Composable
fun JSearchBar(
    modifier: Modifier = Modifier,
    placeholder: String = "搜索",
    rightIcon: ImageVector? = null,
    onClick: () -> Unit,
) {
    Row(
        modifier = modifier
            .clip(Shapes.large)
            .background(Color.White)
            .clickable(
                interactionSource = MutableInteractionSource(),
                indication = null,
                onClick = onClick
            ),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Icon(
            Icons.Default.Search,
            contentDescription = null,
            tint = Color.Black,
            modifier = Modifier.padding(7.dp)
        )
        Text(placeholder, color = Grey3, modifier = Modifier.weight(1f))
        rightIcon?.let {
            Icon(it,contentDescription = null,modifier = Modifier.padding(7.dp))
        }
    }
}